#pragma once
#include <string>
#include <array>
#include <vector>
#include <map>
#include <simple_enum.hpp>
#include <cereal/archives/binary.hpp>
#include <cereal/types/string.hpp>
#include <cereal/types/vector.hpp>
#include <cereal/types/array.hpp>
#include <cereal/types/map.hpp>
#include <cereal/types/memory.hpp>
#include <cereal/archives/json.hpp>










struct SimpleArrays
{
    std::array<float, 3> x{};
    std::array<std::map<int, std::array<float, 3>>, 2> y{};
};


template<class Archive>
void serialize(Archive& archive,
               SimpleArrays& m) {
    archive(cereal::make_nvp("x", m.x));
    archive(cereal::make_nvp("y", m.y));
}


struct Vec2f
{
    float x{};
    float y{};
};


template<class Archive>
void serialize(Archive& archive,
               Vec2f& m) {
    archive(cereal::make_nvp("x", m.x));
    archive(cereal::make_nvp("y", m.y));
}


struct Color
{
    int8_t red{};
    int8_t green{};
    int8_t blue{};
};


template<class Archive>
void serialize(Archive& archive,
               Color& m) {
    archive(cereal::make_nvp("red", m.red));
    archive(cereal::make_nvp("green", m.green));
    archive(cereal::make_nvp("blue", m.blue));
}


class Triangle
{
public:

    Triangle(std::array<Color, 3> colors, std::array<Vec2f, 3> vertices)
        : m_colors(std::move(colors)),m_vertices(std::move(vertices)){}
    // 默认构造函数 default constructor
    Triangle() = default;
    // 拷贝构造函数 copy constructor
    Triangle(const Triangle&) = default;
    // 移动构造函数 move constructor
    Triangle(Triangle&&) = default;
    // 拷贝赋值运算符 copy assignment operator
    Triangle& operator=(const Triangle&) = default;
    // 移动赋值运算符 move assignment operator
    Triangle& operator=(Triangle&&) noexcept = default;
    // 析构函数 destructor
    ~Triangle() = default; 
    
    inline const std::array<Color, 3> & get_colors() const { return m_colors; }
    inline std::array<Color, 3>& get_colors_mutable() { return m_colors; }
    inline void set_colors(std::array<Color, 3> colors) { m_colors = std::move(colors); }

    inline const std::array<Vec2f, 3> & get_vertices() const { return m_vertices; }
    inline std::array<Vec2f, 3>& get_vertices_mutable() { return m_vertices; }
    inline void set_vertices(std::array<Vec2f, 3> vertices) { m_vertices = std::move(vertices); }


    template<class Archive>
    void serialize(Archive& archive) {
        archive(cereal::make_nvp("colors", m_colors));
        archive(cereal::make_nvp("vertices", m_vertices));
    }

private:
    std::array<Color, 3> m_colors{};
    std::array<Vec2f, 3> m_vertices{};
};





